<% if remark.new_record? %>
  <%= set_alias("form_redt_#{remark.id}", "form_rnt_#{remark.topic_id}") %>
<% end %>

<% style = remark.new_record? ? '' : 'display:none' %>
<%= form_for remark, remote: true, html: { id: "form_redt_#{remark.id}", style: style } do |f| %>
  <p>回复：<%= remark_floor_text(remark.parent_remark) %>
    <% if remark.new_record? && !remark.parent_remark.nil? %>
      <%= js_tag '取消回复', 
          { "set('remark[parent_remark_id]','')" => "form_rnt_#{remark.topic_id}",
           submit: "form_rnt_#{remark.topic_id}" } %>
    <% end %>
  </p>

  <%# hidden fields %>
  <%= really_submit_tag %>
  <% if remark.new_record? %>
    <%= remark_topic_id_tag(remark) %>
    <%= remark_parent_remark_id_tag(remark) %>
  <% end %>
  <%= f.hidden_field :remark_type %>

  <%# other options & objects %>
  <p>
  <% if remark.topic.belongs_to_question? && remark.new_record? %>
    <%= js_tag_option '普通评论', {
      "set('remark[remark_type]','')" => "form_redt_#{remark.id}",
      submit: "form_redt_#{remark.id}"
    }, remark.remark_type.nil? || remark.remark_type == '' %>
    | <%= js_tag_option '修改建议', {
      "set('remark[remark_type]','suggestion')" => "form_redt_#{remark.id}",
      submit: "form_redt_#{remark.id}"
    }, remark.remark_type == 'suggestion' %>
    <% if (!remark.parent_remark.nil?) && remark.parent_remark.remark_type == 'suggestion' %>
    | <%= js_tag_option '修改确认', {
      "set('remark[remark_type]','confirm')" => "form_redt_#{remark.id}",
      submit: "form_redt_#{remark.id}"
    }, remark.remark_type == 'confirm' %>
    <% end %>
    <% if remark.remark_type == 'suggestion' %>
      <%= render partial: 'question_versions/form',
      locals: { question_version: remark.get_question_version } %>
    <% end %>
  <% elsif remark.topic.belongs_to_question_list? && remark.new_record? %>
    <%= js_tag_option '普通评论', {
      "set('remark[remark_type]','')" => "form_redt_#{remark.id}",
      submit: "form_redt_#{remark.id}"
    }, remark.remark_type.nil? || remark.remark_type == '' %>
    | <%= js_tag_option '添加建议', {
      "set('remark[remark_type]','new')" => "form_redt_#{remark.id}",
      submit: "form_redt_#{remark.id}"
    }, remark.remark_type == 'new' %>
    <% if (!remark.parent_remark.nil?) && 
      (remark.parent_remark.remark_type == 'suggestion' || 
      remark.parent_remark.remark_type == 'new') %>
    | <%= js_tag_option '修改建议', {
      "set('remark[remark_type]','suggestion')" => "form_redt_#{remark.id}",
      submit: "form_redt_#{remark.id}"
    }, remark.remark_type == 'suggestion' %>
    | <%= js_tag_option '修改确认', {
      "set('remark[remark_type]','confirm')" => "form_redt_#{remark.id}",
      submit: "form_redt_#{remark.id}"
    }, remark.remark_type == 'confirm' %>
    <% end %>
    <% if remark.remark_type == 'new' || remark.remark_type == 'suggestion' %>
      <%= render partial: 'question_versions/form',
      locals: { question_version: remark.get_question_version } %>
    <% end %>
  <% end %>

  </p>

  <%# fields %>
  <%= f.text_area :content %><br/>

  <%# operations %>
  <%= f.submit '提交', onclick: 
      create_js_true({"set('really_submit','true')" => "form_redt_#{remark.id}"}) %>
  <% if !remark.new_record? %>
    <%= button_tag '取消', type: 'button', onclick: 
      create_js({ hide: "form_redt_#{remark.id}", show: "div_ri_#{remark.id}"})  %>
  <% end %>
<% end %>
